import storage from "@/utils/storage";
import {
	http,
	Method
} from "@/utils/request.js";

/**
 * 获取当前登录的用户信息
 * @returns {AxiosPromise}
 */
export function getUserInfo() {
	return http.request({
		url: "/users/profile",
		method: Method.GET,
	});
}

/**
 * 修改当前登录的用户信息
 * @returns {AxiosPromise}
 */
export function updateUserInfo(parmas) {
	return http.request({
		url: "/users/profile",
		method: 'PUT',
		data: parmas
	});
}

/**
 * 上传用户头像
 * @returns {AxiosPromise}
 */
export function uploadAvatarFile(parmas) {
	return http.request({
		url: "/upload",
		method: 'POST',
		data: parmas
	});
}

/**
 * 获取未读通知数量
 * @returns {AxiosPromise}
 */
export function unreadCount() {
	return http.request({
		url: "/notification/unread/count",
		method: 'GET',
	});
}

/**
 * 全部标为已读
 * @returns {AxiosPromise}
 */
export function readAll() {
	return http.request({
		url: "/notices/user/read-all",
		method: 'POST',
	});
}

/**
 * 标为已读
 * @returns {AxiosPromise}
 */
export function readNotification(id) {
	return http.request({
		url: `/notices/user/read/${id}`,
		method: 'POST',
	});
}

/**
 * 获取通知列表
 * @returns {AxiosPromise}
 */
export function notificationList(page) {
	return http.request({
		url: "/notices/user",
		method: Method.GET,
		data: page
	});
}


/**
 * 获取底价和抽成
 * @returns {AxiosPromise}
 */
// export function getPlatformInfo() {
// 	return http.request({
// 		url: "/getPlatformInfo",
// 		method: 'GET'
// 	});
// }


/**
 * 获取系统设置跑腿费
 * @returns {AxiosPromise}
 */
export function getPlatformInfo(keys) {
	return http.request({
		url: `/system/configs/key/${keys}`,
		method: 'GET'
	});
}